#coding:utf-8
import xlrd
import csv
import os


def get_test_Data(file_name="test.xlsx", sheet="sheet"):
    if not os.path.exists(file_name):#判断文件是否存在
        return False
    data = xlrd.open_workbook(file_name)
    table = data.sheet_by_name(sheet)
    rows = []
    a = 0 
    for i in range(1, table.nrows):#从第二行开始读取数
        rows.append(table.row_values(i))
    return rows

def get_yaml_data():
    import yaml
    xml_Data = []
    new_xml_data = []
    f = open("2.yaml")
    x = yaml.load(f)
    for i in x:
        xml_Data.append(i.values())
        
    for i in xml_Data:
        t_len = len(i)
        for x in range(t_len):
            xml_val = i[x].strip().replace("\n", "").replace("\r", "")
            xml_val = xml_val.decode('GBK')
            xml_val=xml_val.strip().replace("\n", "").replace("\r", "")
            new_xml_data.append(xml_val)
    return new_xml_data

def get_csv_Data(file_name):
    if not os.path.exists(file_name):#判断文件是否存在
        return False
    rows = []
    with open(file_name, "rb") as f:
        readers = csv.reader(f)
        next(readers, None)
        for row in readers:
            rows.append(row)
    return rows


if __name__ == "__main__":
    print(get_test_Data("test.xlsx", "addCustomerMarking"))
    #print get_csv_Data("test1.csv")
    #print get_yaml_data()
    """
    t = get_yaml_data()
    for i in t:
        t_len = len(i)
        for x in range(t_len):
            xml_val = i[x].strip().replace("\n", "").replace("\r", "")
            print xml_val
    """
